package com.esun.rabbit2.communicaters.sportteryfootballshengfu;

import com.esun.model.sportteryfootballshengfu.SportteryFootballShengfuAgainstInfo;
import com.esun.network.ServerCommunicater;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;
import com.esun.config.BussinessCode;
import com.esun.config.Key;
/** 
* @ClassName: SportteryFootballShengfuAgainstInfoCommunicater 
* @Description: 胜负彩对阵信息接口 
* @author: Liujun liuj@500wan.com
* @date: 2012-4-19 下午2:54:34 
*  
*/
public class SportteryFootballShengfuAgainstInfoCommunicater extends ServerCommunicater{
		
		private String msgServer; // 服务器信息
		private boolean isSucceed = false;
		public String getMsgServer() {
			return msgServer;
		}

		public void setMsgServer(String msgServer) {
			this.msgServer = msgServer;
		}

		public boolean isGetInfoSucceed() throws ClientProtocolException, IOException,
				ParserConfigurationException, SAXException {
			ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
			list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_GET_SHENGFU_DUIZHENXINXI));
			// 写入服务器返回信息
			super.getServerResponse(list, true);
			setMsgServer(super.getErrorMSG());
			if (super.getState() == 100) {
				isSucceed = true;
			} else {
				isSucceed = false;
			}
			return isSucceed;
		}

		public ArrayList<SportteryFootballShengfuAgainstInfo> getAgainstInfoList() {
			
			ArrayList<SportteryFootballShengfuAgainstInfo> listSportteryFootballShengfuAgainstInfos = new ArrayList<SportteryFootballShengfuAgainstInfo>();

			for (int i = 0; i < super.getListResult().size(); i++) {
				SportteryFootballShengfuAgainstInfo sportteryFootballShengfuAgainstInfo = new SportteryFootballShengfuAgainstInfo();
				sportteryFootballShengfuAgainstInfo.setMatchnum(super.getListResult().get(i).get(Key.KEY_MATCHNUM));
				sportteryFootballShengfuAgainstInfo.setSimplegbname(super.getListResult().get(i).get(Key.KEY_SIMPLEGBNAME));
				sportteryFootballShengfuAgainstInfo.setHometeam(super.getListResult().get(i).get(Key.KEY_HOMETEAM));
				sportteryFootballShengfuAgainstInfo.setGuestteam(super.getListResult().get(i).get(Key.KEY_GUESTTEAM));
				sportteryFootballShengfuAgainstInfo.setGametime(super.getListResult().get(i).get(Key.KEY_GAMETIME));
				sportteryFootballShengfuAgainstInfo.setPlurl(super.getListResult().get(i).get(Key.KEY_PLURL));
				
				listSportteryFootballShengfuAgainstInfos.add(sportteryFootballShengfuAgainstInfo);
			}
			return listSportteryFootballShengfuAgainstInfos;
		}
       
		private HashMap<String, String> mapItem(String name, String value) {
			HashMap<String, String> map = new HashMap<String, String>();
			map.put(name, value);
			return map;
		}

	}


